﻿document.onselectstart = function () { return false; }
document.onmousemove = function (e) { return false; }

// 双击股票跳转到走势/K线
function GroupToKLine(name, sel, all) {
    try {
        if (sel == "" || all == "") {
            return "";
        }

        if (sel.substring(0, 1) == "0" || sel.substring(0, 1) == "3") {
            sel = "1" + sel;
        }

        var inputAll = "";
        var arrAll = all.split(",");

        for (var i = 0; i < arrAll.length; i++) {
            if (arrAll[i] == "") {
                continue;
            }

            if (arrAll[i].substring(0, 1) == "0" || arrAll[i].substring(0, 1) == "3") {
                inputAll += "1" + arrAll[i] + ",";
            }
            else {
                inputAll += arrAll[i] + ",";
            }
        }

        inputAll = inputAll.substring(0, inputAll.length - 1);

        var data = "{\"name\": \"" + name + "\",\"sel\": " + sel + ",\"all\": [" + inputAll + "]}";
        //data格式:{"name": "业绩精选-持续优选","sel": 525,"all": [525,300082,300076]}
        //alert(data);
        window.external.OnCallLocalFunction("GroupToKLine", data);
    } catch (ex) {
    }
}

// 单击股票，用于窗口同步
function SyncGoods(code, date) {
    try {
        if (code.length == 6) {
            if (code.substring(0, 1) == "0" || code.substring(0, 1) == "3") {
                code = "1" + code;
            }
        }
        if (date == undefined) {
            date = "";
        }
        window.external.OnCallLocalFunction("SyncGoods", code, date);
    } catch (ex) {
    }
}

//通知昵称变更
function ISTOCK_FUNC_CHANGENICKNAME(nickname) {
    try {
        window.external.OnCallLocalFunction("ISTOCK_FUNC_CHANGENICKNAME", nickname);
    } catch (ex) {
    }
}

//通知头像变更
function ISTOCK_FUNC_CHANGEUSERPIC(userpic) {
    try {
        window.external.OnCallLocalFunction("ISTOCK_FUNC_CHANGEUSERPIC", userpic);
    } catch (ex) {
    }
}

//引导完成任务
function ISTOCK_FUNC_GOTASK(tid) {
    try {
        window.external.OnCallLocalFunction("ISTOCK_FUNC_GOTASK", tid);
    } catch (ex) {
    }
}

//通知客户端任务完成
function ISTOCK_FUNC_COMPLETETASK(tid, inum, name) {
    try {
        window.external.OnCallLocalFunction("ISTOCK_FUNC_COMPLETETASK", tid + "", inum + "", name);
    } catch (ex) {
    }
}

//获取增值权限
function ISTOCK_FUNC_GETUSERRIGHTS() {
    try {
        return window.external.OnCallLocalFunction("ISTOCK_FUNC_GETUSERRIGHTS");
    } catch (ex) {
    }
}

//获取用户权限
function GetUserID() {
    try {
        return window.external.OnCallLocalFunction("GetUserID");
    } catch (ex) {
    }
}

//调用客户端登录窗
function ISTOCK_FUNC_LOGIN() {
    try {
        window.external.OnCallLocalFunction("ISTOCK_FUNC_LOGIN");
    } catch (ex) {
    }
}

//调用客户端注册窗
function ISTOCK_FUNC_REG() {
    try {
        window.external.OnCallLocalFunction("ISTOCK_FUNC_REG");
    } catch (ex) {
    }
}

//登录
function ISTOCK_FUNC_ONREGISTERED(account, pwd) {
    try {
        var data = window.external.OnCallLocalFunction("OnRegistered", account, pwd);
    } catch (ex) {
    }
}

//取消注册
function ISTOCK_FUNC_ONUNREGISTER() {
    try {
        var data = window.external.OnCallLocalFunction("OnUnregister");
    } catch (ex) {
    }
}

//根据股票代码获取股票名称
function ISTOCK_FUNC_GETSECUABBR(secucode) {
    try {
        var secuabbr = window.external.OnCallLocalFunction("ISTOCK_FUNC_GETSECUABBR", secucode);
        
        if (secuabbr != undefined) {
            return secuabbr;
        }
        else {
            return "";
        }
    } catch (ex) {
        return "";
    }
}

//调用客户端快捷键
function ISTOCK_FUNC_HOTKEY(hotkey) {
    try {
        window.external.OnCallLocalFunction("ISTOCK_FUNC_HOTKEY", hotkey);
    } catch (ex) {
    }
}

//游客K线英雄记录
function ISTOCK_FUNC_GUESTRESULT() {
    try {
        //游戏时间（RecDateTime）、股票代码（SecuCode）、K线开始时间（BeginDateTime）、K线结束时间（EndDateTime）、收益率（Profit）
        return window.external.OnCallLocalFunction("ISTOCK_FUNC_GUESTRESULT");
    } catch (ex) {
    }
}

//打开利器
function ISTOCK_FUNC_GOFUNC(funcid) {
    try {
        window.external.OnCallLocalFunction("ISTOCK_FUNC_GOFUNC", funcid);
    } catch (ex) {
    }
}

//检查权限
function ISTOCK_FUNC_CHECKFUNC(funcid) {
    try {
        return window.external.OnCallLocalFunction("ISTOCK_FUNC_CHECKFUNC", funcid);
    } catch (ex) {
    }
}

//获取客户端版本
//function ISTOCK_FUNC_CLIENTVERSION() {
//    try {
//        return window.external.OnCallLocalFunction("ISTOCK_FUNC_CLIENTVERSION", funcid);
//    } catch (ex) {
//    }
//}

function ISTOCK_FUNC_QUOTES(code) {
    try {
        if (code == undefined || code == "") {
            return;
        }

        var codes = "";
        var arrcode = code.split(",");

        for (var i = 0; i < arrcode.length; i++) {
            if (arrcode[i] == undefined || arrcode[i] == "") {
                break;
            }

            if (arrcode[i].length == 6) {
                if (arrcode[i].substring(0, 1) == "0" || arrcode[i].substring(0, 1) == "3") {
                    codes += "1" + arrcode[i] + ",";
                }
                else {
                    codes += arrcode[i] + ",";
                }
            }
        }

        if (codes.substring(codes.length - 1) == ",") {
            codes = codes.substring(0, codes.length - 1);
        }

        var data = "{\"ver\": 1,\"data\": [" + codes + "]}";
        
        window.external.OnCallLocalFunction("ISTOCK_FUNC_QUOTES", data);
    } catch (ex) {
    }
}

function ISTOCK_FUNC_TRADES(code) {
    try {
        var data = "";
        if (code.length == 6) {
            if (code.substring(0, 1) == "0" || code.substring(0, 1) == "3") {
                code = "1" + code;
            }

            data = "{\"ver\": 1,\"data\": [" + code + "]}";
        }
        else {
            data = "{\"ver\": 1,\"data\": []}";
        }
        
        window.external.OnCallLocalFunction("ISTOCK_FUNC_TRADES", data);
    } catch (ex) {
    }
} 

function ISTOCK_FUNC_CHECKUSER(userid,pwd) {
    try {
        return window.external.OnCallLocalFunction("ISTOCK_FUNC_CHECKUSER", userid, pwd);
    } catch (ex) {
    }
}

///判断是否是已加入自选
function is_add_zixuan(code) {
    var nRet = false;
    try {
        //1. 是否±自选接口
        nRet = window.external.OnCallLocalFunction('ISTOCK_FUNC_ZXG', "is", code);
    } catch (e) {

    }
    return nRet;
}
//添加客户端自选股
function ISTOCK_add_zixuan(code)
{
    try {
        //1. ±自选接口
        window.external.OnCallLocalFunction('ISTOCK_FUNC_ZXG', "add", code);
    } catch (e) {

    }
}
//删除客户端自选股
function ISTOCK_del_zixuan(code)
{
    try {
        //1. ±自选接口
        window.external.OnCallLocalFunction('ISTOCK_FUNC_ZXG', "del", code);
    } catch (e) {

    }
}

//跳转客户端评论
function GOTO_COMMENT(code) {
    try {
        //2. 跳转评论
        window.external.OnCallLocalFunction('ISTOCK_FUNC_GOTO_COMMENT', code);
    } catch (e) {

    }
}

//跳转客户端板块
function GOTOKLine(code)
{
    try {
        window.external.OnCallLocalFunction("GotoKLine", code);        
    } catch (e) {

    }
}
//跳转客户端板块
function GotoPaiMing(code)
{
    try {
        window.external.OnCallLocalFunction("GotoPaiMing", code);
    } catch (e) {

    }
}
//跳转用户参赛绑定页面
function ISTOCK_FUNC_GOTO_WDDS()
{
    try {
        var data = window.external.OnCallLocalFunction("ISTOCK_FUNC_GOTO_WDDS");
    } catch (ex) {
    }
}